<template>
	<view class="container" >
		<!-- 导航栏 -->
		<uni-nav-bar dark :fixed="true" shadow background-color="#007AFF" status-bar left-icon="left" left-text="返回"
			titleStyle="{height: '52px'}" :title="client.company" @clickLeft="back">
		</uni-nav-bar>
		<uni-section title="客户基本信息" type="line">
			<view class="example">
				<uni-forms labelPosition="right">
					<uni-forms-item label="单位地址" name="address" >
						<u--text style="padding: 7px 0;" :text="client.address"></u--text>
					</uni-forms-item>
					<uni-forms-item label="联系人" name="person" >
						<u--text style="padding: 7px 0;" :text="client.person" ></u--text>
					</uni-forms-item>
					<uni-forms-item label="联系人电话" name="phone" >
						<u--text style="padding: 7px 0;" :text="client.phone" ></u--text>
					</uni-forms-item>
					<uni-forms-item label="合作类型" name="cooperationType" >
						<u--text style="padding: 7px 0;" :text="client.cooperationType" ></u--text>
					</uni-forms-item>
				</uni-forms>
			</view>
		</uni-section>
		<uni-section title="客户相关合同" type="line">
			<scroll-view class="scroll-list" scroll-y="true">
				<view class="uni-contract-list" v-for="(contract, index) in contracts" :key="index">
					<view class="uni-contract-list-cell" @click="contractClick(contract)">
						<view class="uni-contract-list-body">
							<view class="uni-contract-list-item-content">
								<view class=""><text>{{contract.sender}}</text></view>
								<text class="uni-contract-list-item-content-step">
									<view>
										<span>{{contract.name}}</span></p>
										<span>{{contract.code}} {{contract.CREATE_TIME}}</span>
									</view>
								</text>
							</view>
							<view class="uni-contract-list-item-extra"><text
									class="uni-contract-list-item-extra-text"><span>></span></text></view>
						</view>
					</view>
				</view>
			</scroll-view>
		</uni-section>
		<!-- <uni-section title="客户相关报告" type="line">
			
		</uni-section> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				client: {},
				contracts: [],
				reports: []
			};
		},
		onLoad(option) {
			// 加载客户对应的合同和报告数据
			this.loadClientInfo(option.id);
			this.loadContract(option.id);
		},
		methods: {
			loadClientInfo(id) {
				this.$u.api.client.detail(id).then((res) => {
					this.client = res.data
				})
			},
			loadContract(clientId) {
				this.$u.api.contract.list({clientId}).then((res) => {
					this.contracts = res.rows
				})
			},
			back() {
				this.backPageRefresh();
			},
			contractClick(contract) {
				uni.navigateTo({
					url: `/pages/contract/detail?edit=false&id=${contract.id}`
				});
			}
		}
	}
</script>

<style lang="scss">
	.uni-section {
		margin-top: 0px !important;
		background-color: #eee;
	}
	.example {
		background-color: white;
		padding: 10px 20px 15px 20px;
	}
	.scroll-list {
		background-color: white;
	}
.uni-contract-list-item-content-step {
		margin-top: 2px;
		color: #999;
		font-size: 13px;
		overflow: hidden;
		line-height: 18px;
	}

	.uni-contract-list-item-extra {
		display: flex;
		flex-direction: row;
		justify-content: flex-end;
		align-items: center;
	}

	.uni-contract-list-item-extra-text {
		color: #999;
		font-size: 18px;
	}

	.uni-contract-list-body {
		position: relative;
		display: flex;
		flex-direction: row;
		padding: 12px 15px;
		padding-left: 15px;
		flex: 1;
		overflow: hidden;
	}

	.uni-contract-list-item-content {
		display: flex;
		padding-right: 8px;
		flex: 1;
		color: #3b4144;
		flex-direction: column;
		justify-content: space-between;
		overflow: hidden;
	}

	.uni-contract-list-text-top {
		height: 40rpx;
		overflow: hidden;
		width: 100%;
		line-height: 40rpx;
		font-size: 32rpx;
		display: flex;
		justify-content: space-between;
	}

	.uni-contract-list-text-bottom {
		width: 100%;
		line-height: 28px;
		font-size: 26rpx;
		color: #666666;

		span {
			margin-right: 10rpx;
		}
	}
</style>
